﻿using ElasticSearch.Utility;
using Microsoft.Extensions.DependencyInjection;
using System.Linq;
using System.Reflection;

namespace ElasticsearchCore.IOC
{
    //业务拓展依赖注入
    public static class IocServiceExtension
    {
        public static IServiceCollection RegisterAssembly(this IServiceCollection service)
        {
            //AssemblyHelper.GetAllAssemblies().ForEach(interfaceAssembly =>
            //{
            //    var types = interfaceAssembly.GetTypes().Where(t =>
            //        t.GetTypeInfo().IsInterface && !t.GetTypeInfo().IsGenericType &&
            //        t.GetInterfaces().Contains(typeof(IDependencyDynamicService)));
            //    foreach (var type in types)
            //    {
            //        var implementTypeName = type.Name.Substring(1);
            //        var implementType = AssemblyHelper.GetImplementType(implementTypeName, type);
            //        if (implementType != null)
            //        {
            //            service.AddScoped(type, implementType);
            //        }
            //    }
            //});
            return service;
        }
    }
}
